package loan.calc.datasource.mytransaction;

import com.baomidou.mybatisplus.autoconfigure.SqlSessionFactoryBeanCustomizer;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@ConditionalOnProperty(name = "dynamic-ds-tx", havingValue = "custom", matchIfMissing = false)
@Configuration
public class DynamicDataSourceTransactionConfiguration {

    @Bean
    public SqlSessionFactoryBeanCustomizer sqlSessionFactoryBeanCustomizer() {
        return factoryBean -> {
            factoryBean.setTransactionFactory(new MultiDataSourceTransactionFactory());
        };
    }
}
